package com.yanfan.ccapi.controller;

import com.yanfan.ccapi.service.ICcapiThirdPartyClientService;
import com.yanfan.ccapicode.dao.entity.ThirdPartyClientDO;
import com.yanfan.common.annotation.Log;
import com.yanfan.common.core.controller.BaseController;
import com.yanfan.common.core.domain.AjaxResult;
import com.yanfan.common.core.page.TableDataInfo;
import com.yanfan.common.enums.BusinessType;
import com.yanfan.common.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 云云对接客户端Controller
 *
 * @author kerwincui
 * @date 2025-06-29
 */
@RestController
@RequestMapping("/ccapi/thirdPartyClient")
@Api(tags = "云云对接客户端")
public class CcapiThirdPartyClientController extends BaseController {
    @Autowired
    private ICcapiThirdPartyClientService ccapiThirdPartyClientService;

    /**
     * 查询云云对接客户端列表
     */
//@PreAuthorize("@ss.hasPermi('ccapi:thirdPartyClient:list')")
    @GetMapping("/list")
    @ApiOperation("查询云云对接客户端列表")
    public TableDataInfo list(ThirdPartyClientDO ccapiThirdPartyClient) {
        startPage();
        List<ThirdPartyClientDO> list = ccapiThirdPartyClientService.selectCcapiThirdPartyClientList(ccapiThirdPartyClient);
        return getDataTable(list);
    }

    /**
     * 导出云云对接客户端列表
     */
    @ApiOperation("导出云云对接客户端列表")
    //@PreAuthorize("@ss.hasPermi('ccapi:thirdPartyClient:export')")
    @Log(title = "云云对接客户端", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ThirdPartyClientDO ccapiThirdPartyClient) {
        List<ThirdPartyClientDO> list = ccapiThirdPartyClientService.selectCcapiThirdPartyClientList(ccapiThirdPartyClient);
        ExcelUtil<ThirdPartyClientDO> util = new ExcelUtil<ThirdPartyClientDO>(ThirdPartyClientDO.class);
        util.exportExcel(response, list, "云云对接客户端数据");
    }

    /**
     * 获取云云对接客户端详细信息
     */
    //@PreAuthorize("@ss.hasPermi('ccapi:thirdPartyClient:query')")
    @GetMapping(value = "/{clientId}")
    @ApiOperation("获取云云对接客户端详细信息")
    public AjaxResult getInfo(@PathVariable("clientId") String clientId) {
        return success(ccapiThirdPartyClientService.selectCcapiThirdPartyClientByClientId(clientId));
    }

    /**
     * 新增云云对接客户端
     */
    //@PreAuthorize("@ss.hasPermi('ccapi:thirdPartyClient:add')")
    @Log(title = "云云对接客户端", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增云云对接客户端")
    public AjaxResult add(@RequestBody ThirdPartyClientDO ccapiThirdPartyClient) {
        return toAjax(ccapiThirdPartyClientService.insertCcapiThirdPartyClient(ccapiThirdPartyClient));
    }

    /**
     * 修改云云对接客户端
     */
    //@PreAuthorize("@ss.hasPermi('ccapi:thirdPartyClient:edit')")
    @Log(title = "云云对接客户端", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改云云对接客户端")
    public AjaxResult edit(@RequestBody ThirdPartyClientDO ccapiThirdPartyClient) {
        return toAjax(ccapiThirdPartyClientService.updateCcapiThirdPartyClient(ccapiThirdPartyClient));
    }

    /**
     * 删除云云对接客户端
     */
    //@PreAuthorize("@ss.hasPermi('ccapi:thirdPartyClient:remove')")
    @Log(title = "云云对接客户端", businessType = BusinessType.DELETE)
    @DeleteMapping("/{clientIds}")
    @ApiOperation("删除云云对接客户端")
    public AjaxResult remove(@PathVariable String[] clientIds) {
        return toAjax(ccapiThirdPartyClientService.deleteCcapiThirdPartyClientByClientIds(clientIds));
    }
}
